home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / mach / sparc / simple_lock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-15  |  1.1 KB  |  68 lines

  1. /* Copyright (c) 1994 NeXT Computer, Inc.  All rights reserved.
  2.  * 
  3.  *    File:    mach/sparc/simple_lock.h
  4.  *
  5.  *    This file contains machine dependent code for exclusion
  6.  *    lock handling on SPARC-based products.
  7.  *
  8.  * HISTORY
  9.  * 21-Apr-1994  Mac Gillon at NeXT
  10.  *    Created.
  11.  */
  12.  
  13. #import <mach/boolean.h>
  14.  
  15. #ifndef    _MACH_SPARC_SIMPLE_LOCK_
  16. #define _MACH_SPARC_SIMPLE_LOCK_
  17.  
  18. struct slock {
  19.     volatile boolean_t    locked;
  20. };
  21.  
  22. typedef struct slock    simple_lock_data_t;
  23. typedef struct slock    *simple_lock_t;
  24.  
  25. extern simple_lock_t    simple_lock_alloc(void);
  26. extern void        simple_lock_free(simple_lock_t);
  27. extern boolean_t    simple_lock_try();
  28.  
  29. #if    !defined(DEFINE_SIMPLE_LOCK_PRIMS)
  30. static __inline__
  31. #endif
  32. void
  33. simple_lock_init(
  34.     simple_lock_t    slock
  35. )
  36. {
  37.     slock->locked = FALSE;
  38. }
  39.  
  40. #if    !defined(DEFINE_SIMPLE_LOCK_PRIMS)
  41. static __inline__
  42. #endif
  43. void
  44. simple_lock(
  45.     simple_lock_t    slock
  46. )
  47. {    
  48.     do
  49.         {
  50.         while (slock->locked)
  51.         continue;
  52.     }
  53.     while (!simple_lock_try(slock));
  54. }
  55.  
  56. #if    !defined(DEFINE_SIMPLE_LOCK_PRIMS)
  57. static __inline__
  58. #endif
  59. void
  60. simple_unlock(
  61.     simple_lock_t    slock
  62. )
  63. {
  64.     slock->locked = FALSE;
  65. }
  66.  
  67. #endif    _MACH_SPARC_SIMPLE_LOCK_
  68.